class Node:
    def __init__(self, value, next=None):
        self.value = value
        self.next = next


class QueueError(Exception):
    pass


# 链式队列的方法实现
class LQueue:
    def __init__(self):
        self.front = self.rear = Node(None)

    def is_empty(self):
        return self.front is self.rear

    # 入队
    def enqueue(self, value):
        self.rear.next = Node(value)
        self.rear = self.rear.next

    # 出队
    def dequeue(self):
        if self.is_empty():
            raise QueueError("empty queue")
        self.front = self.front.next
        return self.front.value

    # 清空队列
    def clear(self):
        self.front = self.rear